home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / maestro / source / ntwrkprt / auxfnctn.c next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  1.4 KB  |  32 lines

  1. /* $Header: /Source/Media/drapeau/NetworkProtocol/RCS/auxFunctions.c,v 1.11 91/02/28 07:18:16 drapeau Exp Locker: drapeau $ */
  2. /* $Log:    auxFunctions.c,v $
  3.  * Revision 1.11  91/02/28  07:18:16  drapeau
  4.  * No code changes; this version uses a new version numbering scheme and a new
  5.  * version of RCS.
  6.  * 
  7.  * Revision 1.1  90/10/24  18:28:54  drapeau
  8.  * Initial revision
  9.  *  */
  10.  
  11. static char auxFunctionsRcsid[] = "$Header: /Source/Media/drapeau/NetworkProtocol/RCS/auxFunctions.c,v 1.11 91/02/28 07:18:16 drapeau Exp Locker: drapeau $";
  12.  
  13. #include <stdio.h>
  14. #include <string.h>
  15.  
  16. char* strdup(char* theString)
  17. {
  18.   char*    tempString = NULL;
  19.   int    stringLength = 0;
  20.  
  21.   if (theString == NULL)                        /* Was the string passed in invalid? */
  22.     return((char*)NULL);                        /* Yes, return NULL string */
  23.   stringLength = strlen(theString);                    /* Get the length of the string passed in */
  24.   tempString = (char*) malloc(stringLength + 1);            /* Try to allocate space for a copy of the string passed in */
  25.   if (tempString == NULL)                        /* Was th allocation unsuccessful? */
  26.     return (char*)NULL;                            /* Yes, return a NULL string */
  27.   strcpy(tempString,theString);                        /* Allocation successful, copy old string to new string */
  28.   tempString[stringLength] = '\0';                    /* Terminate new string */
  29.   return(tempString);                            /* Return pointer to the new string */
  30. }                                    /* end function strdup */
  31.  
  32.